package com.yunji.order.context.builder;

import com.yunji.common.model.dto.LoginInfo;
import com.yunji.common.utils.uuid.UUIDUtils;
import com.yunji.order.domain.PayoutDO;
import com.yunji.order.dto.PayoutCreateDTO;
import com.yunji.order.emuns.PayoutStatusEnum;

import java.util.Date;

/**
 * @author : peter-zhu
 * @date : 2025/4/11 17:00
 * @description : TODO
 **/
public class PayoutBuilder {
    private final PayoutDO payout;

    private PayoutBuilder() {
        this.payout = new PayoutDO();
    }

    public static PayoutBuilder builder() {
        return new PayoutBuilder();
    }
    public PayoutBuilder buildUserInfo(LoginInfo info) {
        payout.setBelongId(info.getBelongId());
        payout.setUserId(info.getUserId());
        payout.setUserType(info.getUserType());
        payout.setPhone(info.getPhone());
        payout.setRealName(info.getRealName());
        payout.setUserName(info.getUsername());
        return this;
    }

    public PayoutBuilder buildPayout(PayoutCreateDTO vo) {
        payout.setAmount(vo.getAmount());
        payout.setChannel(vo.getChannel());
        payout.setPayoutRealName(vo.getRealName());
        payout.setPayoutAccount(vo.getAccount());
        return this;
    }

    public PayoutDO build() {
        payout.setPayoutCode(UUIDUtils.payoutCode());
        payout.setApplyStatus(PayoutStatusEnum.APPLYING.getCode());
        payout.setApplyTime(new Date());
        return this.payout;
    }
}
